package Sequence;

public class Test0376 {

}

class Solution0376_1 {
    public int wiggleMaxLength(int[] nums) {
        int length = nums.length,last = nums[0],ans = 1,stat=0;

        for (int i = 1; i < length; i++) {
            int now = nums[i];
            if (now == last){
                continue;
            }else if(now > last && stat <= 0){
                ans++;
                stat = 1;
            }else if(now < last && stat >= 0) {
                ans++;
                stat = -1;
            }
            last = now;
        }

        return ans;
    }
}
